<template>
  <div class="partner">
    <Search @sendInfo="receiveInfo" :searchTitle="'合作商搜索:'" />
    <div class="list">
      <el-row>
        <el-col :span="4"
          ><el-button icon="iconfont icon-jiahao" type="warning" @click="newCreate"
            >新建</el-button
          ></el-col
        >
      </el-row>
      <el-table
        ref="singleTable"
        :data="regionInfo.currentPageRecords"
        highlight-current-row
        center
        style="width: 100%"
      >
        <el-table-column align="center" label="序号" width="150" type="index" height="45">
        </el-table-column>
        <el-table-column align="center" property="name" label="区域名称" width="300">
        </el-table-column>
        <el-table-column align="center" property="nodeCount" label="点位数" width="260">
        </el-table-column>
        <el-table-column
          align="center"
          property="remark"
          label="备注说明"
          width="300"
        ></el-table-column>
        <el-table-column align="center" label="操作">
          <template slot-scope="{ row }">
            <el-button type="info" icon="el-icon-search" size="mini" @click.native="seeDetails(row)"
              >查看详情</el-button
            >
            <el-button size="mini" type="primary" icon="el-icon-edit" @click.native="aditInfo(row)"
              >修改</el-button
            >
            <el-button
              type="danger"
              icon="el-icon-delete"
              size="mini"
              @click.native="deleteInfo(row.id)"
              >删除</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <Pagination
        :searchTaskList="regionInfo"
        @currentSizeChange="(value) => (regionInfoParams.pageSize = value)"
        @currentPageChange="(value) => (regionInfoParams.pageIndex = value)"
      />
    </div>
  </div>
</template>

<script>
import partnerSearchAPI from '@/api'
export default {
  name: 'Partner',
  data() {
    return {
      // 搜索框
      searchInfo: '',
      // 获取合作商数据的参数
      partnerInfoParams: {
        pageIndex: 1,
        pageSize: 10
      },
      // 获取区域数据的参数
      regionInfoParams: {
        pageIndex: 1,
        pageSize: 10
      }
    }
  },
  created() {
    this.fecthPartnerList(this.regionInfoParams)
  },

  methods: {
    // 搜索框事件
    receiveInfo(value) {
      if (this.searchInfo !== value) {
        this.searchInfo = value
        this.partnerInfoParams.pageIndex = 1
        this.fecthPartnerList({ ...this.regionInfoParams, name: this.searchInfo })
      }
    },
    async fecthPartnerList(data) {
      const res = await partnerSearchAPI(data)
      console.log(res.data)
    }
  }
}
</script>
<style lang="less" scoped></style>
